#ifndef _REVERSE_H
#define _REVERSE_H

#include "dependence.h"

_MINI_BEGIN

template<class Contain, class Biditerator>
class reverse_iterator
{
public:
    typedef typename Contain::iterator iterator;
    typedef typename Contain::const_iterator const_iterator;
    typedef typename Contain::value_type value_type;
    typedef typename Contain::pointer pointer;
    typedef typename Contain::reference reference;
    typedef typename Contain::const_value_type const_value_type;
    typedef typename Contain::const_pointer const_pointer;
    typedef typename Contain::const_reference const_reference;

    typedef reverse_iterator<Contain, Biditerator> _Self;

public:
    reverse_iterator(Biditerator it)
        :_it(it)
    {}

    reference operator*() const { return *_it; } // ?
    pointer operator->() const { return &(operator*()); }
    bool operator!=(const _Self& rhs) const { return _it != rhs._it; }
    bool operator==(const _Self& rhs) const { return _it == rhs._it; }
    _Self& operator++()
    {
        --_it;
        return *this;
    }
    _Self operator++(int)
    {
        _Self tmp = _Self(_it);
        --_it;
        return tmp;
    }
    _Self& operator--()
    {
        ++_it;
        return *this;
    }
    _Self operator--(int)
    {
        _Self tmp = _Self(_it);
        ++_it;
        return tmp;
    }
private:
    Biditerator _it;
};

_MINI_END

#endif